#ifndef _TCP_H_
#define _TCP_H_

/*
 * int port
 *  |   tcp server port
 *
 * int (*client_open)(int fd, void **pdata)
 *  |   a new client connected, will call this. if return -1 in this function, tcp will close client fd.
 *  |   fd: client socket fd
 *  |   pdata: user data ptr. MUST link fd to here, so client_read can return it.
 *
 * int (*client_read)(int *ret_fd, void *data)
 *  |   when client is readable(data is coming), will call this
 *  |   ret_fd: when user read socket failed, please return -1 and client fd to here, so epoll can \
 *  |           delete it
 *  |   data: user data
 * */
int launch_server(
        int port,
        int (*client_open)(int fd, void **pdata),
        int (*client_read)(int *ret_fd, void *data)
        );

#endif
